/**
 * Demo4422 基本使用示例
 */

import Demo4422 from '../index.js';
const demo = new Demo4422();

console.log('=== Demo4422 基本使用示例 ===\n');

// 1. 包信息
console.log('1. 包信息:');
console.log(demo.getInfo());
console.log();

// 2. 问候功能
console.log('2. 问候功能:');
console.log(demo.greet());
console.log(demo.greet('张三'));
console.log();

// 3. 计算功能
console.log('3. 计算功能:');
const a = 15, b = 3;
console.log(`${a} + ${b} = ${demo.calculate(a, b, 'add')}`);
console.log(`${a} - ${b} = ${demo.calculate(a, b, 'subtract')}`);
console.log(`${a} × ${b} = ${demo.calculate(a, b, 'multiply')}`);
console.log(`${a} ÷ ${b} = ${demo.calculate(a, b, 'divide')}`);

try {
  demo.calculate(a, 0, 'divide');
} catch (error) {
  console.log(`错误: ${error.message}`);
}
console.log();

// 4. 随机字符串生成
console.log('4. 随机字符串生成:');
console.log('8位:', demo.generateRandomString());
console.log('10位:', demo.generateRandomString(10));
console.log('16位:', demo.generateRandomString(16));
console.log();

// 5. 综合示例
console.log('5. 综合示例:');
['Alice', 'Bob', 'Charlie'].forEach(user => {
  const greeting = demo.greet(user);
  const randomId = demo.generateRandomString(6);
  console.log(`${greeting} (ID: ${randomId})`);
});

console.log('\n=== 示例结束 ===');

// 导出示例函数（可选）
export const runBasicExample = () => {
  console.log('运行基本示例...');
  // 这里可以包含示例逻辑
}; 